home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
C++ für Kids
/
C++ for kids.iso
/
Buch
/
Monster8.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1999-01-23
|
2KB
|
83 lines
//---------------------------------------------------------------------------
#include <vcl\vcl.h>
#pragma hdrstop
#include "Monster8.h"
//---------------------------------------------------------------------------
#pragma resource "*.dfm"
const String Pfad = "c:\\cpp\\buch\\";
class TMonster
{
public:
virtual void operator << (String Bild);
};
//---------------------------------------------------------------------------
TMonster *WerWohl;
bool Modus;
int Zufall;
TForm1 *Form1;
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void TMonster::operator << (String Bild)
{
String Name = Bild.SubString(1, Bild.Length()-4);
Form1->Image1->Picture->LoadFromFile (Pfad+Bild);
Form1->Panel1->Caption = Name;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
randomize ();
WerWohl = new TMonster;
Timer1->Interval = 500;
Timer1->Enabled = false;
Modus = true;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Button1Click(TObject *Sender)
{
if (Modus)
{
Timer1->Enabled = true;
Button1->Caption = "Stop";
}
else
{
Timer1->Enabled = false;
Button1->Caption = "Start";
}
Modus = !Modus;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
Zufall = random(5);
switch (Zufall)
{
case 0:
*WerWohl << "Frank.bmp";
break;
case 1:
*WerWohl << "Albert.bmp";
break;
case 2:
*WerWohl << "Sigmund.bmp";
break;
case 3:
*WerWohl << "Jekyll.bmp";
break;
case 4:
*WerWohl << "Hyde.bmp";
}
}
//---------------------------------------------------------------------------